package com.zhongpengcheng.blog.event;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;

import java.util.concurrent.TimeUnit;
import java.util.jar.JarEntry;

/**
 * @author ZhongPengCheng
 * @version 1.0
 * @since 2021-12-04 16:10:00
 */
@Getter
public class TimedCacheDataEvent extends ApplicationEvent {
    private static final long serialVersionUID = 4497221970667261347L;
    /**
     * redis的key
     */
    private final String key;
    /**
     * 要保存的redis value
     */
    private final String value;
    /**
     * 过期时间
     */
    private final long timeout;
    /**
     * 过期时间单位
     */
    private final TimeUnit unit;

    public TimedCacheDataEvent(String key, String value, long timeout, TimeUnit unit) {
        super(key);
        this.key = key;
        this.value = value;
        this.timeout = timeout;
        this.unit = unit;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
